<?php 
$GLOBALS['Md'] = "Exchange";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
MYTCONN();
include("main.obj.mex");
include("nav.views.mex");

	include('Lib/pr.exchange.mex'); 
	include('Lib/list.seckeys.mex');

form_pr('STExchange','msetts.php','','post'); ?>
<div class="title">Tarifas de Exchange</div>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
          <tr bgcolor="#C7C7C7">
            <td><?php 
	  $Qur = "SELECT ref AS ID, name AS NAME FROM systemoffice.main_offices";
	  mn_field('select','ED','OFFICE','',$Qur,'','',''); ?></td>
            <td><?php 
	  $Qur = "SELECT ntr_ID AS ID, ntr_Tarifa AS NAME FROM hd_Tarifas";
	  mn_field('select','ED','CURRENCY','',$Qur,'','',''); ?></td>
            <td><?php 
	  $Qur = "SELECT miso_Cod_elite AS ID, miso_ID AS NAME FROM hd_monedasiso where miso_Cod_elite > 0";
	  mn_field('select','ED','CURRENCY','',$Qur,'','',''); ?></td>
            <td colspan="3">
              <?php mn_field('submit','ED','New','Nova','','','',''); ?></td>
          </tr>
          <tr bgcolor="#C7C7C7">
            <td>Loja</td>
            <td>Tarifa</td>
            <td>Moeda</td>
            <td>Estado</td>
            <td width="120">Activado a:</td>
          </tr>
          <?php  
		$GET = $GLOBALS['MYT']->db_array("SELECT 
									exchange_offices.REF,
									main_settings_currency.icon AS CURRENCY,
									main_offices.name AS OFFICE,
									exchange_offices.STATUS,
									DATE(TimeStart) AS TimeStart,
									TimeEnd,
									ntr_Tarifa AS Exc_Tarifa
					FROM exchange_offices
					INNER JOIN systemoffice.main_offices ON OFFICE = main_offices.ref
					INNER JOIN hd_Tarifas ON ntr_ID = Exc_Tarifa
					INNER JOIN systemoffice.main_settings_currency ON CURRENCY = main_settings_currency.ref
					ORDER BY main_offices.ref");
	for ($m = 1; $m <= $GET[0]; $m++) { 
			
		echo '<tr bgcolor="#F2F2F2">
		<td>'.$GET[$m]['OFFICE'].'</td>
		<td>'.$GET[$m]['Exc_Tarifa'].'</td>
		<td>'.$GET[$m]['CURRENCY'].'</td>
		<td>';
		$Qur = "Activo;Inactivo#1;0";
		mn_field('hselect','ED','STATUS',$GET[$m]['STATUS'],$Qur,'','','');
		echo '</td>
		<td>'.$GET[$m]['TimeStart'].'</td>
		</tr>';
	}
?>
        </table></td>
        <td valign="top"><?php 
		$MODE = 'FullList';
		//include('Lib/list.seckeys.mex'); ?></td>
  </tr>
    </table>
	<?php mn_field('submit','ED','SAVESET','Salvar Altera��es','','','',''); ?>
</form>